package com.zsgeek.wisdchain.qutu.view.home.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zsgeek.wisdchain.qutu.R;
import com.zsgeek.wisdchain.qutu.base.model.DrawableBean;
import com.zsgeek.wisdchain.qutu.tools.ImageUtils;
import com.zsgeek.wisdchain.qutu.tools.TextUtils;

import java.util.List;

/**
 * 上传图片证据 适配器
 */
public class C2cAppealAgainstPicAdapter extends BaseQuickAdapter<DrawableBean, BaseViewHolder> {
    private Context content;

    public C2cAppealAgainstPicAdapter(Context content, List<DrawableBean> data) {
        super(R.layout.activity_c2c_appeal_against_item, data);
        this.content = content;
    }


    @Override
    protected void convert(BaseViewHolder baseViewHolder, DrawableBean bean) {
        try {
            if (bean.getType() == DrawableBean.TYPE_PIC) {
                ImageUtils.loadImage(content, bean.getPicturePath(), (ImageView) baseViewHolder.getView(R.id.upload_data_iv));
                baseViewHolder.setGone(R.id.cancel_upload_data_iv, true);
            } else {
                baseViewHolder.setGone(R.id.cancel_upload_data_iv, false);
                if (TextUtils.isEmpty(bean.getPicturePath())) {
                    if (baseViewHolder.getAdapterPosition() < 6)
                        baseViewHolder.setImageResource(R.id.upload_data_iv, R.mipmap.upload_data_icon_bg);
                } else {
                    ImageUtils.loadImage(content, bean.getPicturePath(), (ImageView) baseViewHolder.getView(R.id.upload_data_iv));
                }
            }
            baseViewHolder.addOnClickListener(R.id.upload_data_iv);
            baseViewHolder.addOnClickListener(R.id.cancel_upload_data_iv);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
